<template>
  <el-dropdown @command="selectLanguage">
    <span class="currentLang">
      {{ $i18n.locale === 'zh' ? '语言：中文' : 'Lanauge: English' }}
      <i class="el-icon-arrow-down el-icon--right" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale === 'zh'">中文</el-dropdown-item>
      <el-dropdown-item command="en" :disabled="$i18n.locale === 'en'">English</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  methods: {
    selectLanguage(newLanguage) {
      // console.log(newLanguage)
      localStorage.setItem('language', newLanguage)
      this.$i18n.locale = newLanguage
    }
  }
}
</script>

<style>
.currentLang {
  color: white;
  font-size: 16px;
}
</style>
